package com.java.zhuiyun.api.book_mark.controller;

import com.java.zhuiyun.api.book_mark.service.BookMarkService;
import com.java.zhuiyun.common.response.CommonResult;
import io.swagger.models.auth.In;
import org.apache.ibatis.annotations.Delete;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @ClassName BookMarkController
 * @Description TODO
 * @Author wuwan
 * @Date 2023/8/31 10:26
 **/
@RestController
@CrossOrigin
@RequestMapping("/bookMark")
public class BookMarkController {

    @Autowired
    private BookMarkService bookMarkService;
    /*
    * @Author wuwan
    * @Description 用户收藏点击事件
    * @Date 2023/8/31 10:29
    * @Return
    * @param null
    */
    @PostMapping("/addBookMark")
    public CommonResult addBookMark(Integer uid,Integer cid){
        return CommonResult.ok(bookMarkService.addBookMark(uid,cid));
    }
    /*
    * @Author wuwan
    * @Description 收藏课程查询
    * @Date 2023/8/31 10:33
    * @Return
    * @param null
    */
    @GetMapping("/getBookMark")
    public CommonResult getBookMark(Integer uid){
        return CommonResult.ok(bookMarkService.getBookMark(uid));
    }
    /*
    * @Author wuwan
    * @Description 个人信息取消课程收藏
    * @Date 2023/8/31 16:53
    * @Return
    * @param null
    */
    @PostMapping("/delBookMark")
    public CommonResult delBookMark(Integer id){
        return CommonResult.ok(bookMarkService.delBookMark(id));
    }
    /*
     * @Author wuwan
     * @Description 课程取消收藏 //王旭用
     * @Date 2023/8/31 16:53
     * @Return
     * @param null
     */
    @PostMapping("/delBookMarkCourse")
    public CommonResult delBookMarkCourse(Integer uid, Integer cid){
        return CommonResult.ok(bookMarkService.delBookMarkCourse(uid,cid));
    }

    /*
    * @Author wuwan
    * @Description 是否收藏课程
    * @Date 2023/9/3 20:11
    * @Return
    * @param null
    */
    @GetMapping("/getUser")
    public CommonResult getUser(Integer uid, Integer cid) {
        return CommonResult.ok(bookMarkService.getUser(uid, cid));
    }
}
